//:C15:VirtualInDestructors.cpp 
// Virtual calls inside destrctors
#include <iostream>
using namespace std;

class Base
{
    public:
        virtual ~Base()
        {
            cout << "Base1()\n";
            f();
        }
        virtual void f(){ cout << "Base::f()\n"; }
};

class Derived : public Base
{
    public:
        ~Derived(){ cout << "~Derived()\n"; }
        void f(){ cout << "Derived::f()\n"; }
};

int main(void)
{
    Base * bp = new Derived;   // Upcast
    delete bp;                               
}
